#include <QQuaternion>
#include "particle_shooter.h"

void ParticleShooter::addParticles(ParticleSystem *particleSystem
        ,float currentTime
        ,int count) {
    for (int i=0; i<count; ++i) {
        float rx = QRandomGenerator::global()->bounded(1.0) - 0.5; 
        float ry = QRandomGenerator::global()->bounded(1.0) - 0.5; 
        float rz = QRandomGenerator::global()->bounded(1.0) - 0.5; 
        QQuaternion qua = QQuaternion::fromEulerAngles(m_angleVariance * rx
                , m_angleVariance * ry
                , m_angleVariance * rz);
        QVector3D vd = qua.rotatedVector(m_direction);
        particleSystem->addParticle(m_position
                , m_color
                , vd
                , currentTime);
    };
}
